<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>元素的定时执行</title>
</head>
<body>
        <script>
           var i = 0;
          function foo() {
                i = i + 5;
              console.log(i);
              if(i>200){                        //if 要写在function里面
                  clearInterval(timer)
          }

          }
         var timer = setInterval(foo,100);   //停止重复执行

        </script>

</body>
</html>